package day04;

import java.awt.*;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class control {

    public static void main(String[] args) throws IOException {
//        Scanner sc = new Scanner(System.in);
        ServerSocket ss = new ServerSocket(6200);//创建服务
        System.out.println("等待中...");
        Socket s = ss.accept(); //等待
        System.out.println("来了！");
        OutputStream out = s.getOutputStream();//获取初级输出管道
        ObjectOutputStream oos = new ObjectOutputStream(out); //创建东西的输出管道
        for (;;) {
//            System.out.println("x:");
//            int x = sc.nextInt();
//            System.out.println("y:");
//            int y = sc.nextInt(); //自定义一个位置，准备让对方移动的坐标

            int x = MouseInfo.getPointerInfo().getLocation().x;
            int y = MouseInfo.getPointerInfo().getLocation().y;
            mouse_info mouse = new mouse_info();//准备一个东西，鼠标信息，将两个坐标存进去
            mouse.x = x;
            mouse.y = y;
            oos.writeObject(mouse);//把这东西存进去
            oos.flush();
        }

    }
}
